<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // rest参数扩展：  ...

        // 自定义求和函数,其中args可以接收任意数量的参数
        function  add(...args){
            let sum = 0;
            for(let i = 0; i < args.length; i++){
                sum += args[i];
            }
            return sum;
        }

        // 测试：
        console.log(add(100,200));          //300
        console.log(add(100,200, 300));     //600
        console.log(add(10, 20, 30, 40));   //100
        console.log(add(10, 20, 30, 40, 50));// 150
    </script>
</body>
</html>